package egovframework.npqs.pqi.mobile.common;

import net.sf.json.JSONSerializer;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

public class JSONResponseUtil {

	
	 /**
     * JSON View 화면 처리를 위해 JSON변환 후 ResponseEntity로 반환.
     * @param obj
     * @return
     */
    public static ResponseEntity getJSONResponse(Object obj){
        String json = new JSONSerializer().toJSON(obj).toString();
        
        System.out.println("================================json  start===========================");
        System.out.println("json = "+json);
        System.out.println("================================json end===========================");
        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.add("Content-Type", "text/html; charset=UTF-8");
        return new ResponseEntity(json,responseHeaders, HttpStatus.CREATED);
    }
     
    /**
     * JSON View 화면 처리를 위해 JSON변환 후 ResponseEntity로 반환.
     * @param obj
     * @return
     */
    public static String getJSONString(Object obj){
        return new JSONSerializer().toJSON(obj).toString();
    }
}
